<template>
  <div class="panel-group">
    <div class="sigma-content">
      <div class="sigma-title">今日机构情况</div>
      <div class="institution-content">
        <div
          class="institution"
          style="background-color: #FFF3E2;color: #FDA41F;"
        >
          <div class="name">
            进件成功量
          </div>
          <div class="num">{{ list.agencySuccessNum }}</div>
        </div>

        <div
          class="institution"
          style="background-color: #E5ECFF;color: #376DF7;"
        >
          <div class="name">
            进件成功率
          </div>
          <div class="num">{{ list.agencySuccessPercent }}</div>
        </div>
        <div
          class="institution"
          style="background-color: #E9F8F3;color: #35CD99;"
        >
          <div class="name">
            在线机构数
          </div>
          <div class="num">{{ list.onlineAgencyNum }}</div>
        </div>
        <div
          class="institution"
          style="background-color: #FFEAEA;color: #ED5B5B;"
        >
          <div class="name">
            曝光值低于500
          </div>
          <div class="num">{{ list.lowExposureNum }}</div>
        </div>
      </div>
    </div>
    <div class="sigma-content online">
      <div class="sigma-title">在线机构占比</div>
      <OnlineInstitution :listQuery="listQuery" class="pieChart" />
    </div>
  </div>
</template>

<script>
import { agencySituation } from '@/api/home';
import { timestampToTime } from '@/utils/index';
require('echarts/theme/macarons'); // echarts theme
import resize from '../components/mixins/resize';
import OnlineInstitution from '../componentsTwo/OnlineInstitution.vue';
export default {
  mixins: [resize],
  components: {
    OnlineInstitution
  },
  data() {
    return {
      timeNow: [
        new Date(new Date().toLocaleDateString()).getTime(),
        new Date(new Date().toLocaleDateString()).getTime() +
          (24 * 60 * 60 * 1000 - 1)
      ],
      listQuery: {
        startTime: '',
        endTime: ''
      },
      list: {}
    };
  },
  mounted() {
    this.listQuery.startTime = timestampToTime(this.timeNow[0]);
    this.listQuery.endTime = timestampToTime(this.timeNow[1]);
    this.getAgencySituation();
  },
  methods: {
    async getAgencySituation() {
      const res = await agencySituation(this.listQuery);
      if (res.data.code === 200) {
        this.list = res.data.data;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.panel-group {
  width: 100%;
  height: 400px;
  padding: 16px;
  background-color: #ffffff;
  .sigma-content {
    .sigma-title {
      width: 200px;
      font-size: 16px;
      border-left: 3px solid #376df7;
      padding: 0 4px;
      margin: 2px 0;
      line-height: 11px;
    }
    .pieChart {
      // margin-top: 10px;
    }
    .institution-content {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      align-items: center;
      padding: 10px 0;
      .institution {
        width: 48%;
        padding: 12px 0;
        text-align: center;
        margin-bottom: 10px;
        border-radius: 10px;
        .name {
          font-size: 14px;
        }
        .num {
          font-size: 24px;
          margin-top: 4px;
        }
      }
    }
  }
  .online {
    height: 180px;
  }
}
</style>
